﻿@model System.Collections.Generic.List<HQPad.Models.RecordItem>
           
<h2>Adventure record</h2>

    @using (Html.BeginForm("AddRecord", "Character", FormMethod.Post, new { @name = "addRecordForm", @id = "addRecordForm" }))
    { 
        <fieldset class="form block">
            <legend>Add record</legend>
            <div class="field-item">
                <div class="label"><label for="eventDate">Date:</label></div>
                <input type="datetime" id="eventDate" name="eventDate" class="date-time" value="@Html.Raw(DateTime.Now.ToString("dd/MM/yyyy"))" />
                <span class="date-error"></span>
            </div>
            <div class="field-item">
                <div class="label"><label for="eventDescription">Event:</label></div>
                <input type="text" id="eventDescription" name="eventDescription" class="textbox" />
            </div>
            <div class="field-item">
                <div class="label"><label for="eventPoints">Points:</label></div>
                <input type="number" id="eventPoints" name="eventPoints" class="number" value="1" min="1" max="9999" />
                <span class="points-error"></span>
            </div>
            <input type="submit" value="Add" />
        </fieldset>
    }

@if (Model == null || Model.Count == 0)
{
    <p>You don't yet have any adventure records.</p>
}
else
{
<table>
    <thead>
        <tr>
            <th>Date</th>
            <th>Event</th>
            <th>Points</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    @{
    int index = 0;
     }
        @foreach (HQPad.Models.RecordItem item in Model)
        {
        <tr @Html.Raw((index % 2 == 0) ? "class=\"even\"" : "class=\"odd\"")>
            <td><time datetime="@Html.Raw(item.Date.ToString("YYYY-MM-DD"))">@Html.Raw(item.Date.ToString("dd MMM yyyy"))</time></td>
            <td>@Html.Raw(item.Description)</td>
            <td>@Html.Raw(item.Points.ToString())</td>
            <td>
                <input type="hidden" class="record-id" value="@Html.Raw(item.ID.ToString())" />
                @Html.ActionLink("Edit", "EditRecord", "Character", new { id = item.ID }, new { @class = "edit-record modal-window", @target = "_blank" })
                @Html.ActionLink("Remove", "RemoveRecord", "Character", new { id = item.ID }, new { @class = "remove-record" })
            </td>
        </tr>
            index++;
        }
    </tbody>
</table>
}